package com.practice.java8中双冒号方法引用如何使用;

import java.util.function.Consumer;

/**
 * @program: tenghw-practice-demo
 * @author: tenghw
 * @create: 2024-01-06 16:12
 * @Version 1.0
 * @description: 测试 类名::静态方法
 **/
public class Demo3 {
    public static void main(String[] args) {
        // 使用lambda表达式，返回一个Consumer实例
        Consumer<Student> consumer = item-> System.out.println(item.getName());
        consumer.accept(new Student("吕蒙",18));

        // 使用方法引用
        Consumer<Student> consumer1 = Student::printStudentName;
        consumer1.accept(new Student("吕蒙",18));
    }

}